<?php
namespace Modules\Shop\Database\factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Modules\Core\Models\User;
use Ramsey\Uuid\Uuid;

class PayTransactionFactoryFactory extends Factory
{
    /**
     * The name of the factory's corresponding model.
     *
     * @var string
     */
    protected $model = \Modules\Shop\Models\PayTransactionFactory::class;

    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        return [
            'tenant_id' => 1,
            'transaction_id' => Uuid::uuid4()->getHex(),
            'status' => Arr::random([1, 2]),
            'model_type' => get_class(new \Modules\Shop\Models\Spu()),
            'model_order_id' => now()->addDays(rand(-20, 20))->format('YmdHis').now()->timestamp,
            'pay_driver' => 'Wechat',
            'pay_gateway' => 'miniapp',
            'pre_total_fee' => $this->faker->randomNumber(4),
            'total_fee' => $this->faker->randomNumber(4),
            'fee_type' => 'CNY',
            'expired_at' => now()->addMinutes(rand(10, 20)),
            'transaction_code' => Str::random(32),
            'payment_at' => now()->addMinutes(rand(5, 10)),
            'create_ip' => '0.0.0.0',
            'create_by' => User::first()->userid
        ];
    }
}

